/**
* ...
* @author $(DefaultUser)
*/

package com.chasekernan.hxnova.raceeditor;

import com.chasekernan.hxnova.core.races.Race;
import com.chasekernan.hxnova.server.IO;
import neko.FileSystem;

class Base {
    static var window : swhx.Window;
    static var flash : swhx.Flash;

    static function main() {
        swhx.Application.init();
        
        window = new swhx.Window("HxNova -- Race Editor", 477, 461);
        window.maximizeIcon = false;
        window.resizable = false;
        
        var context = new haxe.remoting.Context();
		context.addObject("Base", Base);
        
        flash = new swhx.Flash(window, context);
        flash.setAttribute("src","ui.swf");
        flash.start();
        
        window.visible = true;
        swhx.Application.loop();
        swhx.Application.cleanup();
    }
    
    //TODO: Define entry point for race save
    public static function save(r : String, name : String) {
        //var loc = "C:\\HxNova\\" + name + ".hxnova-race";
        var loc = systools.Dialogs.saveFile("Save Race: " + name, "Save", "C:\\") + ".hxnova-race";
        IO.writeToFile(IO.compress(r), loc);
    }
    
}